
package com.idealighter.game.games.texaspoker.handler;

import com.idealighter.game.core.annotation.ResMsgHandler;
import com.idealighter.game.gamehall.dto.SeatInfo;
import com.idealighter.game.games.texaspoker.TexaspokerPlayer;
import com.idealighter.game.games.texaspoker.message.ResNextSeatMsg;
import com.idealighter.game.message.core.ResMessage;
import com.idealighter.game.robot.core.Player;
import com.idealighter.game.robot.handler.ResMessageHandler;
import com.idealighter.utils.code.RandCodeUtil;

import java.util.concurrent.TimeUnit;


@ResMsgHandler(505220)
public class ResNextSeatHandler implements ResMessageHandler {

  // private static final Logger LOG = LoggerFactory.getLogger(ResNextSeatHandler.class);

  @Override
  public void action(Player player, ResMessage message) {
    ResNextSeatMsg msg = (ResNextSeatMsg) message;
    TexaspokerPlayer texaspokerPlayer = (TexaspokerPlayer) player;
    SeatInfo seatInfo = texaspokerPlayer.seat(player.playerId);
    if (seatInfo != null && seatInfo.getOrder() == msg.getOrder()) {
      // if (msg.getRaisetBet() == 0) {
      // gameStrategy.curBet = 0;
      // }
      int time = RandCodeUtil.random(texaspokerPlayer.domain.getTimeMin(),
          texaspokerPlayer.domain.getTimeMax());
      if (time == 0) {
        time = RandCodeUtil.random(3, 6);
      }
      player.schedule(() -> texaspokerPlayer.betDesision(msg.getCurMaxBet(), msg.getRaisetBet()),
          time, TimeUnit.SECONDS);

      // if (time == 0) {
      // System.err.println("TimeMIn:" + gameStrategy.domain.getTimeMin() + "TimeMax: " +
      // gameStrategy.domain.getTimeMax());
      // }
    }
  }

  // /**
  // * @param player .
  // * 下注
  // */
  // public void betDesision(Player player, int type, int bet) {
  // ReqBetDecisionMsg msg = new ReqBetDecisionMsg();
  // msg.setType(type);
  // msg.setBet(bet);
  // player.sendMsg(msg);
  // }
}
